package iface;

import java.awt.BorderLayout;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ClientInterface implements Runnable {
	private Thread runner;
	private String userName;
	private String password;
	private JFrame mainWindow = new JFrame("Hotel-Manager");
	private Socket socket;
	
	public ClientInterface(Socket s) {
		setSocket(s);
		if(runner == null){
			runner = new Thread(this);
			runner.start();
		}
	}
	
	@Override
	public void run() {
		try {
			DataOutputStream out = new DataOutputStream(getSocket().getOutputStream());
			BufferedReader in = new BufferedReader(new InputStreamReader(getSocket().getInputStream()));
			
			setUserName(JOptionPane.showInputDialog(null,"Digite seu nome de usuario: "));
			setPassword(JOptionPane.showInputDialog(null,"Digite sua senha: "));
			
			
			
			mainWindow.setSize(800,600);
			mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			mainWindow.setLayout(new BorderLayout());
			mainWindow.setVisible(true);
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public Thread getRunner() {
		return runner;
	}

	public void setRunner(Thread runner) {
		this.runner = runner;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
	}

	public Socket getSocket() {
		return socket;
	}

}
